import os
import sys

# 请在此输入您的代码
res = False


def dfs(dep, ans):
    # 结束条件
    if dep+1 == n:
        if ans == 42:
            global res
            res = True
        return

    # 遍历
    # 加法
    cnt = ans + a[dep + 1]
    dfs(dep + 1, cnt)

    # 减法
    cnt = ans - a[dep + 1]
    dfs(dep + 1, cnt)

    # 乘法
    cnt = ans * a[dep + 1]
    dfs(dep + 1, cnt)

    # 除法
    if a[dep + 1] != 0:
        cnt = ans // a[dep + 1]
        dfs(dep + 1, cnt)


s = input().split()
n = len(s)
a = [0] * len(s)
for i in range(len(s)):
    if s[i] == 'A':
        a[i] = 1
    elif s[i] == 'K':
        a[i] = 13
    elif s[i] == 'Q':
        a[i] == 12
    elif s[i] == 'J':
        a[i] == 11
    else:
        a[i] = int(s[i])

dfs(0, a[0])
if res:
    print("YES")
else:
    print("NO")